// Canvas Table 主题配置
// 使用 Tailwind CSS 的颜色系统

export interface CanvasTableTheme {
  // 主色调
  primary: {
    50: string
    100: string
    200: string
    300: string
    400: string
    500: string
    600: string
    700: string
    800: string
    900: string
    950: string
  }
  
  // 中性色
  neutral: {
    50: string
    100: string
    200: string
    300: string
    400: string
    500: string
    600: string
    700: string
    800: string
    900: string
    950: string
  }
  
  // 状态色
  success: string
  warning: string
  error: string
  info: string
  
  // 特殊颜色
  selection: string
  hover: string
  modified: string
  inserted: string
  deleted: string
  border: string
  
  // 字体
  fontFamily: string
  fontSize: {
    xs: number
    sm: number
    base: number
    lg: number
  }
}

// 默认主题（基于 Tailwind 的颜色）
export const defaultTheme: CanvasTableTheme = {
  // 使用 Tailwind 的 blue 色系作为主色
  primary: {
    50: '#eff6ff',
    100: '#dbeafe',
    200: '#bfdbfe',
    300: '#93c5fd',
    400: '#60a5fa',
    500: '#3b82f6', // primary-500
    600: '#2563eb',
    700: '#1d4ed8',
    800: '#1e40af',
    900: '#1e3a8a',
    950: '#172554'
  },
  
  // 使用 Tailwind 的 gray 色系作为中性色
  neutral: {
    50: '#f9fafb',
    100: '#f3f4f6',
    200: '#e5e7eb',
    300: '#d1d5db',
    400: '#9ca3af',
    500: '#6b7280',
    600: '#4b5563',
    700: '#374151',
    800: '#1f2937',
    900: '#111827',
    950: '#030712'
  },
  
  // 状态色
  success: '#10b981', // green-500
  warning: '#f59e0b', // amber-500
  error: '#ef4444',   // red-500
  info: '#3b82f6',    // blue-500
  
  // 特殊颜色
  selection: '#dbeafe', // blue-100
  hover: '#f3f4f6',     // gray-100
  modified: '#fef3c7',  // amber-100
  inserted: '#d1fae5',  // green-100
  deleted: '#fee2e2',   // red-100
  border: '#e5e7eb',    // gray-200
  
  // 字体
  fontFamily: 'ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif',
  fontSize: {
    xs: 11,
    sm: 13,
    base: 14,
    lg: 16
  }
}

// 深色主题
export const darkTheme: CanvasTableTheme = {
  primary: {
    50: '#172554',
    100: '#1e3a8a',
    200: '#1e40af',
    300: '#1d4ed8',
    400: '#2563eb',
    500: '#3b82f6',
    600: '#60a5fa',
    700: '#93c5fd',
    800: '#bfdbfe',
    900: '#dbeafe',
    950: '#eff6ff'
  },
  
  neutral: {
    50: '#030712',
    100: '#111827',
    200: '#1f2937',
    300: '#374151',
    400: '#4b5563',
    500: '#6b7280',
    600: '#9ca3af',
    700: '#d1d5db',
    800: '#e5e7eb',
    900: '#f3f4f6',
    950: '#f9fafb'
  },
  
  success: '#34d399', // green-400
  warning: '#fbbf24', // amber-400
  error: '#f87171',   // red-400
  info: '#60a5fa',    // blue-400
  
  selection: '#1e40af', // blue-800
  hover: '#1f2937',     // gray-800
  modified: '#78350f',  // amber-900
  inserted: '#064e3b',  // green-900
  deleted: '#7f1d1d',   // red-900
  border: '#374151',    // gray-700
  
  fontFamily: 'ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif',
  fontSize: {
    xs: 11,
    sm: 13,
    base: 14,
    lg: 16
  }
}

// 创建主题助手函数
export function createTheme(overrides: Partial<CanvasTableTheme>): CanvasTableTheme {
  return {
    ...defaultTheme,
    ...overrides
  }
}

// 主题转换函数（转换为 TableRenderer 需要的格式）
export function themeToTableOptions(theme: CanvasTableTheme) {
  return {
    primaryColor: theme.primary[500],
    headerBgColor: theme.neutral[100],
    headerTextColor: theme.neutral[900],
    cellBgColor: '#ffffff',
    cellTextColor: theme.neutral[900],
    selectedBgColor: theme.selection,
    selectedTextColor: theme.neutral[900],
    modifiedBgColor: theme.modified,
    borderColor: theme.border,
    fontFamily: theme.fontFamily,
    fontSize: theme.fontSize.sm
  }
} 